package com.dw.user.controller;


import com.dw.common.entitys.BaseResponse;
import com.dw.common.utils.ResultUtils;
import com.dw.model.auth.dtos.AuthUserDTO;
<<<<<<< HEAD
import com.dw.model.user.dtos.QueryUserDTO;
import com.dw.model.user.dtos.updateUserDTO;
=======
import com.dw.model.user.dtos.updateUserDTO;
import com.dw.model.user.entitys.UserInfo;
>>>>>>> next
import com.dw.model.user.vos.GetUserVO;
import com.dw.user.service.UserInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 用户信息表(UserInfo)表控制层
 *
 * @author makejava
 * @since 2024-10-05 14:47:33
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserInfoController {

    @Resource
    private UserInfoService userInfoService;

    /**
     * AuthUserClient调用的方法
     * @param authUserDTO
     * @return
     */
    @PostMapping("/login")
    public BaseResponse<Long> login(@RequestBody AuthUserDTO authUserDTO) {
        log.info("AuthUserClient调用login的参数:{}",authUserDTO);
        Long id = userInfoService.login(authUserDTO);
        return ResultUtils.success(id);
    }

    /**
<<<<<<< HEAD
     * 完善用户信息
     */
    @PostMapping("/update")
    public BaseResponse<Boolean> update(@RequestBody updateUserDTO updateUserDTO){
        log.info("完善用户信息传参:{}",updateUserDTO);
        Boolean result = userInfoService.updateUser(updateUserDTO);
        return ResultUtils.success(result);
    }

    /**
     * 根据id获取用户信息，无参数时获取当前登录用户信息
     */
    @PostMapping("/info")
    public BaseResponse<GetUserVO> info(@RequestBody QueryUserDTO queryUserDTO){
        log.info("根据id获取用户信息，无参数时获取当前登录用户信息:{}",queryUserDTO);
        GetUserVO result = userInfoService.info(queryUserDTO.getUserId());
        return ResultUtils.success(result);
    }


=======
     * 根据id查询用户信息
     */
    @GetMapping("/{id}")
    public BaseResponse<GetUserVO> getUserById(@PathVariable("id") Long id) {
        log.info("根据id查询用户信息参数:{}", id);
        GetUserVO getUserVO = userInfoService.getUserById(id);
        return ResultUtils.success(getUserVO);
    }

    /**
     * 完善用户信息
     */
    @PostMapping("/update")
    public BaseResponse<Boolean> updateUser(@RequestBody updateUserDTO updateUserDTO) {
        log.info("完善用户信息参数:{}", updateUserDTO);
        boolean flag = userInfoService.updateUser(updateUserDTO);
        return ResultUtils.success(flag);
    }

    /**
     * 用户签到
     */
    @GetMapping("/sign/{userId}")
    public BaseResponse<Boolean> sign(@PathVariable Long userId) {
        Boolean result = userInfoService.sign(userId);
        return ResultUtils.success(result);
    }

>>>>>>> next
}

